package com.eureka.controller;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    Logger logger= LoggerFactory.getLogger(UserController.class);

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/test")
    public String  test(Integer id){

        logger.info("传入信息: {}",id);
        /**
         * 模拟向Cate发送请求
         */
//        String url="http://localhost:8888/cate/test";
        String url="http://EUREKACATE/cate/test";
//        RestTemplate restTemplate=new RestTemplate();
        String forObject = restTemplate.getForObject(url, String.class);
        System.out.println("模拟响应信息: "+forObject);

        return "User 8988"+"模拟响应信息: "+forObject;
    }
}
